##　蓝图使用练习
from flask import Blueprint, render_template, request
# from app1 import app1_blue
# from flask import Blueprint

app1_blue = Blueprint('app1_blue', __name__, static_url_path='/', static_folder='static', template_folder='templates') # static_url_path='/app1',

@app1_blue.route('/')
def show_info():
    return 'app1 Blue_print Info!'


@app1_blue.route('/add')
def add_index():
    """基本web页面"""
    return render_template('add_index.html')


@app1_blue.route('/form0')
def form_demo0():
    """基本web_input页面"""
    return render_template('form_demo0.html')


# form.validate()
@app1_blue.route('/form1', methods=['GET', 'POST'])
def form_demo1():
    from app1.forms import EmployeeForm
    form = EmployeeForm(request.form)

    # if request.method == 'POST' and form.validate():
    if form.validate_on_submit():
        return str(form.data)
    return render_template('form_demo1.html', form=form)


# form.{% import 'bootstrap/wtf.html' as wtf %}
@app1_blue.route('/form2', methods=['GET', 'POST'])
def form_demo2():
    from app1.forms import EmployeeForm
    form = EmployeeForm(request.form)

    # if request.method == 'POST' and form.validate():
    if form.validate_on_submit():
        return str(form.data)
    return render_template('form_bootstrap.html', form=form)
